<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>考试安全客户端</title>
</head>
<body style="background-color:#fff;">
	<div style="margin:auto auto; margin-top:50px; width:1000px; height:600px; background-color:#fff;">
		<div style="margin:auto auto; margin-top:30px; width:450px; height:300px; background-color:green; border-radius: 10px;">
			<div style="padding-top:20px; padding-left:20px; font-weight:bold; font-size:20px; color:white; font-family: Microsoft YaHei;">
				机位号
			</div>
			<div id="seatno" style="margin:auto auto; margin-top:-10px; text-align:center; font-size:180px; font-weight:bold; color:yellow; font-family: Microsoft YaHei;">
				0
			</div>
		</div>
		<div style="margin:auto auto; margin-top:30px; width:450px; height:106px; background-color:#eee; border-radius: 10px;">
			<div style="padding:15px 50px; font-size:16px; font-family: Microsoft YaHei; ">
				请输入 6 位考试口令
			</div>
			<div style="margin:auto auto; text-align:center; font-size:10px; ">
			<form method="post" name="form1" id="form1" action="http://safeexamclient.com/login/key_do" onsubmit="return check();">
				<input type="text" id="key" name="key" value="" style="width: 232px; font-size: 16px; font-weight: bold; letter-spacing:10px; text-align: center; padding: 5px;" maxlength="6" > 
				&nbsp; 
				<input type="submit" style="width: 90px; padding: 5px ;" value=" 进 入 ">
			</form>	
			</div>
		</div>		
	</div>
</body>
</html>

<script>
	/* 提交前检查 */
	function check(){
		var key = document.getElementById("key").value; //获取输入值
		var re = /^[A-Z0-9]*$/; 						//正择表达式，大写字母或数字
		var len = key.length;
		if (len != 6) {
			alert("提示：考试口令必须是6位，请重新输入");
			return false;
		}
		if (!re.test(key)) {
			alert("提示：您输入的不是大写字母或数字，请重新输入");
			return false;
		}		
		return true;
	}

	/* 显示机位号 */
	function GetRequest() {
		var url = location.search; 
		var theRequest=new Array();  
		if (url.indexOf("?") != -1) {
			var str = url.substr(1);       //截取出字符串
			strs = str.split("&");         //分割成为数组
			for(var i = 0; i < strs.length; i ++) {
				//将传递的参数组合key=>val 形式
				//不要用unescape，要用decodeURI，否则中文乱码
				theRequest[strs[i].split("=")[0]]=decodeURI(strs[i].split("=")[1]); 
			}
		}
		return theRequest;
	}

	//调用方法 例："index.html?a=1&b=2&c=中国"
	var request = GetRequest();
	/*
	var a=request['a'];
	var b=request['b'];
	var c=request['c'];
	alert(a);
	alert(b);
	alert(c);
	*/

	//调用方法 例："Exam.html?seat=12"
	var seat = request['seat'];
	if(typeof seat === "undefined"){
		document.getElementById("seatno").innerHTML = 0;
	}else{
		document.getElementById("seatno").innerHTML = seat;
	}
</script>
